package com.jagochan.module.business.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jagochan.module.business.pojo.po.Topic;
import com.jagochan.module.business.mapper.TopicMapper;
import com.jagochan.module.business.service.TopicService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;

@RequiredArgsConstructor
@Service
public class TopicServiceImpl extends ServiceImpl<TopicMapper, Topic> implements TopicService {


    @Override
    public Map<Long, Topic> mapByIds(Set<Integer> idSet) {
        if (idSet.isEmpty()) return new HashMap<>();
        List<Topic> topicList = listByIds(idSet);
        if (topicList == null) return new HashMap<>();
        return topicList.stream().collect(Collectors.toMap(Topic::getId, item -> item));
    }
}